﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using EthnicEdu.Service;

namespace EthnicEdu
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            if (App.JobID == 2) //uploader
            {
                ApplicationBar.IsVisible = true;
            }
            else if (App.JobID == 3) {
                ApplicationBar.Buttons.Clear();
                ApplicationBarIconButton btnNavigatToVerifier = new ApplicationBarIconButton();
                btnNavigatToVerifier.Text = "Verify";
                btnNavigatToVerifier.IconUri = new Uri("/Images/Verify.png",UriKind.Relative);
                btnNavigatToVerifier.IsEnabled = true;
                ApplicationBar.Buttons.Add(btnNavigatToVerifier);
                btnNavigatToVerifier.Click += new EventHandler(btnNavigatToVerifier_Click);
            }
            else
                ApplicationBar.IsVisible = false;

            App.myService.GetAllCategoryAsync();
            App.myService.GetAllCategoryCompleted += new EventHandler<Service.GetAllCategoryCompletedEventArgs>(myService_GetAllCategoryCompleted);

        }

        void btnNavigatToVerifier_Click(object sender, EventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/Pages/QuestionDetailPage.xaml", UriKind.Relative));
        }

        void myService_GetAllCategoryCompleted(object sender, Service.GetAllCategoryCompletedEventArgs e)
        {
            this.DataContext = e.Result;
        }
      

        private void WrapPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {

    //        {EthnicEdu.Service.View_Category}
    //CategoryId: 1
    //CategoryIdField: 1
    //CategoryName: "Study"
    //CategoryNameField: "Study"
            App.CategoryID = (lsCategories.SelectedValue as EthnicEdu.Service.View_Category).CategoryId;
            NavigationService.Navigate(new Uri("/Pages/ViewerListQuestion.xaml", UriKind.Relative));
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/Pages/UploaderListQuestion.xaml", UriKind.Relative));
        }

      

        
    }
}